home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boostrs.arc / MOVEBG.ASM < prev    next >
Assembly Source File  |  1985-10-22  |  4KB  |  175 lines

  1. ;**************************************************
  2. ;
  3. ;       Procedure MOVEBG(Var PAGE : AnyBuf;
  4. ;                              X1 : ColumnType;
  5. ;                              Y1 : RowType;
  6. ;                              X2 : ColumnType;
  7. ;                              Y2 : RowType;
  8. ;                              X3 : ColumnType;
  9. ;                              Y3 : RowType ) ;
  10. ;
  11. ;       1. Captures block at (X1,Y1) and (X2,Y2)
  12. ;       2. Refreshes screen with PAGE
  13. ;       3. Moves saved block from stack to (X3,Y3)
  14. ;
  15. ;**************************************************
  16. MoveBg  proc    near
  17.         push    bp
  18.     mov    bp,sp
  19.     push    ds
  20. ;
  21. ;
  22. ;*** Compute number of lines to move
  23. ;
  24.     mov    ax,[bp+12]    ; value of Y1 into AX
  25.     mov    cx,[bp+08]    ; value of Y2 into CX
  26.         sub     cx,ax           ; CX = Y2 - Y1
  27.     inc    cx        ; CX = Number of lines
  28. ;
  29. ;
  30. ;*** Compute length of each move
  31. ;
  32.     mov    ax,[bp+14]    ;  X1 into AX
  33.     mov    dx,[bp+10]    ;  X2 into DX
  34.     sub    dx,ax        ;  DX = X2 - X1
  35.     inc    dx        ;  DX = num WORDS/line
  36.     shl    dx,1        ;  DX = num bytes/line
  37. ;
  38. ;*** Compute workspace needed on stack
  39. ;
  40. wksp:    sub    sp,dx
  41.     loop    wksp
  42.     mov    ax,ss
  43.     mov    es,ax
  44.     mov    di,sp        ;  ES:DI has stack address
  45. ;
  46. ;*** Determine Video address
  47. ;
  48.     mov    bx,449h
  49.     xor    ax,ax
  50.     mov    ds,ax
  51.     mov    al,[bx]
  52.     cmp    al,7
  53.     jne    graphx
  54.     mov    dx,0B000h
  55.     jmp    c001
  56. graphx:
  57.     mov    dx,03DAh    ; for IBM CGA,
  58. VR:    in    al,dx        ; we must do this
  59.     and    al,1000b    ; so we won't see
  60.     jz    vr        ; snow
  61.     dec    dx
  62.     dec    dx
  63.     mov    al,21h
  64.     out    dx,al        ; disable video
  65.     mov    dx,0B800h
  66. c001:    push    dx
  67.  
  68. ;
  69. ;*** Compute source address for move to stack
  70. ;
  71.     mov    bx,[bp+12]    ;  Y1 into BX
  72.         dec     bx              ;  (Y1-1)
  73.     mov    dx,bx        ;  Save in DX
  74.     mov    cl,7
  75.     shl    dx,cl        ;  (Y1-1) * 128
  76.     mov    cl,5
  77.     shl    bx,cl        ;  (Y1-1) *  32
  78.     add    bx,dx        ;  (Y1-1) * 160
  79.     mov    ax,[bp+14]    ;  X1 into AX
  80.     dec    ax        ;  (X1-1)
  81.     shl    ax,1        ;  2 * (X1-1)
  82.     add    bx,ax        ;  BX = (Y1-1) * 160 + 2 * (X1-1) - 2
  83.     mov    si,bx        ;  Source string offset in SI
  84.     pop    ds        ;  DS:SI has starting address
  85. ;
  86.     mov    ax,[bp+12]    ;  value of Y1 into AX
  87.     mov    dx,[bp+08]    ;  value of Y2 into DX
  88.         sub     dx,ax           ;  DX = Y2 - Y1
  89.     inc    dx        ;  DX = Number of lines
  90.     push    dx
  91. ;
  92.     mov    ax,[bp+14]    ;  X1 into AX
  93.     mov    cx,[bp+10]    ;  X2 into CX
  94.     sub    cx,ax        ;  CX = X2 - X1
  95.     inc    cx        ;  CX = number of WORDS/line
  96.     push    cx
  97.     push    ds
  98. ;
  99. ;*** Move block from screen to stack
  100. ;
  101.     mov    bx,cx
  102.     shl    bx,1
  103.     mov    ax,160
  104.     sub    ax,bx        ;  AX has SI increment
  105.     cld
  106. MOVE1:    push    cx
  107. rep    movsw
  108. ;
  109.     pop    cx
  110.     dec    dx
  111.     jz    DONE1
  112.     add    si,ax
  113.     jmp    MOVE1
  114. ;
  115. ;*** Copy screen image passed as parameter to video display
  116. ;
  117. DONE1:  mov     di,0
  118.     pop    es
  119.     mov    cx,2000
  120.     mov    si,[bp+16]
  121.     mov    ds,[bp+18]
  122.     cld
  123. rep    movsw
  124. ;
  125. ;*** Move saved object from stack workspace to new location on screen
  126. ;
  127. DONE2:    mov    bx,[bp+04]    ;  Y3 into BX
  128.         dec     bx              ;  (Y3-1)
  129.     mov    dx,bx        ;  Save in DX
  130.     mov    cl,7
  131.     shl    dx,cl        ;  (Y3-1) * 128
  132.     mov    cl,5
  133.     shl    bx,cl        ;  (Y3-1) *  32
  134.     add    bx,dx        ;  (Y3-1) * 160
  135.     mov    ax,[bp+06]    ;  X3 into AX
  136.     dec    ax        ;  (X3-1)
  137.     shl    ax,1        ;  2 * (X3-1)
  138.     add    bx,ax        ;  BX = (Y3-1) * 160 + 2 * (X3-1) - 2
  139.     mov    di,bx        ;  Destination string offset in DI
  140. ;
  141. ;*** Move block
  142. ;
  143.     pop    cx
  144.     pop    dx
  145.         mov     si,sp
  146.     mov    ax,ss
  147.     mov    ds,ax
  148.     mov    ax,160
  149.     sub    ax,cx
  150.     sub    ax,cx        ;  AX = DI adjust
  151. ;
  152. MOVER:    push    cx
  153.         cld
  154. rep    movsw
  155. ;
  156.     pop    cx
  157.     dec    dx
  158.     jz    DONE3
  159.     add    di,ax
  160.         jmp     MOVER
  161. ;
  162. DONE3:    mov    dx,es
  163.     cmp    dx,0B800h
  164.     jnz    return
  165.     mov    dx,03D8h
  166.     mov    al,29h
  167.     out    dx,al
  168. return: mov    sp,bp
  169.     sub    sp,2
  170.         pop     ds
  171.         mov     sp,bp
  172.         pop     bp
  173.     ret    16
  174. MoveBg  endp
  175.